package com.itheima.wemedia.runner;

import com.heima.utils.common.SensitiveWordUtil;
import com.itheima.wemedia.dao.WmSensitiveDao;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
@Slf4j
public class WmNewsApplicationRunner implements ApplicationRunner {
    @Autowired
    private WmSensitiveDao wmSensitiveDao;
    //为了避免数据创建多次将该DFA 构建铭感词汇放入创建项目开始
    @Override
    public void run(ApplicationArguments args) throws Exception {
    log.info("项目启动完成>>>>>>>>>>");
    //获取所有铭感词汇
    List<String> words=wmSensitiveDao.queryAllBydFind();
    //初始化 铭感词列表 DFA结构
        SensitiveWordUtil.initMap(words);

    }
}
